﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MvcShoppingMall.HtmlHelper
{
    public class PageList<T> : List<T>
    {
        //当前页
        public int PageIndex { get; set; }
        //每页显示
        public int PageSize { get; set; }
        //总条数
        public int TotalConut { get; set; }
        //总页数
        public int TotalPage { get; set; }

        /// <summary>
        /// 分页数据源构造函数
        /// </summary>
        /// <param name="source">全部数据</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">每页显示</param>
        public PageList(List<T> source, int pageIndex, int pageSize, ref int totalCount, ref int totalPage)
        {
            PageIndex = pageIndex;
            PageSize = pageSize;
            TotalConut = totalCount;
            TotalPage = totalPage;
            this.AddRange(source);
        }    
        /// <summary>
        /// 当前是否存在上一页
        /// </summary>
        public bool HasPreviousPage
        {
            get { return (PageIndex > 1); }
        }
        /// <summary>
        /// 当前是否存在下一页
        /// </summary>
        public bool HasNextPage
        {
            get { return (PageIndex < TotalPage); }
        }

    }
}